/*
 * FortressData - data structure containing all kinds of fortress pieces
 *
 * Copyright 2007 James W. Hofmann
 *
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 */

#if flash9
import flash3f.Images;
#end
import Type;

class FortressData
// either walls, castles or towers. Maintains health, type, shoot status, etc.
{

	public var health : Int;
	public var tx : Int;
	public var ty : Int;
	public var iscastle : Bool;
	public var castlecontrol : Bool;
	public var mystyle : Int;
	public var shooter : Shooter;
		
	public function new(ntx : Int, nty : Int, style : Int)
	{
	
		tx = ntx;
		ty = nty;		
		iscastle = false;
		mystyle = style;
	
		if (style==1) // wall
		{
			health = 15;
		}
		
		if (style==2) // castle
		{
			iscastle = true;
			castlecontrol = true;
			shooter = new Shooter(0, this);
			health = 100;
		}

		if (style==3) // tower
		{
			shooter = new Shooter(1, this);
			health = 50;
		}

	}

	public function upgrade(next : Int)
	{
		shooter.upgrade(next);
		health = 50;
	}
	
	public function kill()
	{
		if (shooter!=null)
		{
			Game.cur.shooterman.shooters.remove(shooter);
		}
		castlecontrol = false;
	}

	public function upgradekill()
	{
		// this is a "fake kill" used for upgrading the tower
		Game.cur.map[this.tx][this.ty].fort = null;
	}
	
	public function upgradeunkill()
	{
		Game.cur.map[this.tx][this.ty].fort = this;
	}
		
}
